import * as THREE from "three";
import { BeadData } from "./BraceleData";

/**
 * 珠子
 */
export default class Bead {
    /**
     * 使用数据初始化
     * @param {BeadData} data 
     */
    constructor(data) {
        this.radius = data.radius;
        this.path = data.path;

        this.mesh = new THREE.Group();
    }

    add(scene) {
        this.scene = scene;
        this.mesh.add(scene);
        this.mesh.scale.set(this.radius, this.radius, this.radius);
    }

    setData(data) {
        this.radius = data.radius;
        this.path = data.path;
        if (!this.mesh) {
            return;
        }

        this.mesh.scale.set(this.radius, this.radius, this.radius);
    }

    getData() {
        return {
            radius: this.radius,
            path: this.path
        };
    }
}